-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ROSE containers more friendly #485
Conversation
@nirs can you take a look ? |
rose/server/web/index.html
Outdated
@@ -9,11 +9,20 @@ | |||
|
|||
<body> | |||
<div id="content"> | |||
<a href="settings.html" id="settings-link">Settings</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to make this settings/
and rename settings.html to settings/index.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to '/settings/index.html'
note that the python server we are using can't automatically show index.html
files when the request is /
it show 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bennypowers i currently put the web component in settings-form
file in the same dir, is there a convention for how to name web components ? where to put tehm ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, name the module the same as the tag name
<a href="settings.html" id="settings-link">Settings</a> | ||
<a href="#" id="info-btn">Info</a> | ||
|
||
<div id="info-panel" class="hidden"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class=hidden vs hidden vs use a pre-built custom-element with aria announce stuff ready to go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARIA is a little out of scope here :-)
we may implement when we move to web components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While aria is not necessary, the experience must be available to screen reader users
<button id="stop" disabled>Stop</button> | ||
<button id="music_ctl">Music</button> | ||
<button id="reset">Reset</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<button id="reset">Reset</button> | |
<button id="reset" type="reset">Reset</button> |
rose/server/web/settings.css
Outdated
@@ -0,0 +1,84 @@ | |||
body.dark-theme { | |||
background-color: #2c3e50; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using red hat design tokens
rose/server/web/settings.html
Outdated
document.addEventListener('DOMContentLoaded', loadDrivers); | ||
</script> | ||
</head> | ||
<body class="dark-theme"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use prefers-color-scheme
rose/server/web/settings.html
Outdated
<input type="text" id="driver2" name="driver2" class="input-field"> | ||
</div> | ||
<div class="form-group"> | ||
<button type="submit" class="submit-button">Send</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need the type here. or really the class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a type to prevent form event trigger, can I avoid it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, sorry, it now a regular button ... this one do need the type :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you need to prevent default, do it in the custom element class, otherwise havea route on the http server that accepts the http formdata, for progressive enhancement
0e6c0a4
to
ee55c43
Compare
Cool demo! But about 20x times too big to review. Can you break up to small easy to review commits? In general the idea that the server connects to the drivers looks strange and harder to use.
The current model when the clients connects to the server is better. I don't see why we need Regarding the problems:
Why do you want to run the client forever? The client is something you run temporarily when testing or during a game.
This is incorrect. We use simple line based JSON lines RPC protocol that is easy to write The protocol for for communicating with the server is not related to the the driver pyc file in any way. The dependency is the python client which can be replaced with a client written in any other language.
These libraries are not python 2.7 oriented, they just mature libraries that were popular Twisted is awesome because it let you run multiple services clients in the same process. I don't think there is anything replacing it. For example, if you want to add an IRC clinet reporting game results to IRC channel, this is really easy in twisted. autobahn is web socket library with twisted integartion. websoket is the best way to commmunicate with the game UI, allowing real time updates. Why replace it? pytest is the best testing library for python (if not the best testing library for anything). Since we used twisted, it was very easy to add xmlrpc server for the admin tool, but we It will be more productive to open issues for any problem and discuss them. |
@nirs thanks This PR is to make the Game more Openshift ready, when I run pods in Openshift, I want to deploy my pods, and let them run.
"As an instructor I want to ask the students to deploy their drivers to the cluster, and then run matches using an already running server and drivers" removing the xmlrpc connection between the driver and server makes it easy to run the game-engine (named "server") and the driver (named "client") as Pods that live as good citizens of the cluster.
you don't need to re-run the server, the idea is that the server is running all the time.
this is easy when running on a cluster: oc get services -n students
the server is good citizen of the cluster, it is deployed once and run forever, you can run several game-engines "servers" but they will need to have a URL per server and can't run using a load balancer, the drivers on the other hand are stateless and can run in deployments of more then one.
the game-engine (named "server" because it is currently called this way) is a client or the driver (named "client" because it is currently called this way) server, and does not care if the driver is connected or not, it just pool it, it can get an answer of miss it, nothing will happen if no answer is given except the the car will continue forward and the user will get a notice. |
@nirs ok, so it uses twisted protocol instead of xmlrpc ... not sure if it's that easy to implement in other languages, but I didn't try :-) |
Yes, I will see how to make it more clear 👍 |
Twisted vs asyncio asyncio is a part of the standard library. no need to install it, it's a nice plus for using it. To sum things up, Twisted is awesome, but asyncio is integrated with python and is "the new cool thing" |
pytest vs unittest unittest: Part of the Python standard library. You don't need to install anything extra to use it. so it's one plus for unittest and one for pytest :-) |
ee55c43
to
d548f5e
Compare
asyncio does not replace twisted - it is just the core of twisted, and I think that twisted I don't see how this is related to making the containers more friendly.
Testing with pytest is so much better than anything else and it worth the tiny effort I cannot think about more unrelated topic to making the container more friendly :-) Let focus on the friendliness issue, because this seem to the purpose of this PR. |
For basic HTTP client server communication, you don't need twisted, asyncio is doing all that is needed.
ok :-) |
22e309d
to
1b64380
Compare
@nirs hi, a. reverted ci to use pytest, still need to translate the tests. |
f64802d
to
23670ca
Compare
53afd6b
to
e2c8463
Compare
- update readme - move pipenv to the docs package - update how to check exercises doc Signed-off-by: yzamir <kobi.zamir@gmail.com>
- update makefile - update ci to use make file - remove travis config - update git ignore - update helper scripts Signed-off-by: yzamir <kobi.zamir@gmail.com>
- remove compiled examples that will only work on one version of python Signed-off-by: yzamir <kobi.zamir@gmail.com>
- add settings page - make the dashboard lighter Signed-off-by: yzamir <kobi.zamir@gmail.com>
- make a rose-common container based on ubi ptyhon - remove classes and methods that are not used (network, configuration) Signed-off-by: yzamir <kobi.zamir@gmail.com>
- move from twisted to asyncio - move from autobahn to websockets - add specific configuration files - add makefile - add dockerfile Signed-off-by: yzamir <kobi.zamir@gmail.com>
Signed-off-by: yzamir <kobi.zamir@gmail.com>
Signed-off-by: yzamir <kobi.zamir@gmail.com>
- move from twisted to asyncio - move from autobahn to websockets - move files into a game directory Signed-off-by: yzamir <kobi.zamir@gmail.com>
Signed-off-by: yzamir <kobi.zamir@gmail.com>
Signed-off-by: yzamir <kobi.zamir@gmail.com>
e2c8463
to
f3c182c
Compare
Signed-off-by: yzamir <kobi.zamir@gmail.com>
aba7194
to
c98bcfb
Compare
Signed-off-by: yzamir <kobi.zamir@gmail.com>
53c301a
to
e8e4db7
Compare
} | ||
|
||
render() { | ||
this.shadowRoot.innerHTML = ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting take. I would have thought to not use shadow DOM in this case and just this.querySelector, but this is good too
You may choose to use a template element is a static init block, but this isn't reusable so the gains are few
If you'll stick with shadow DOM, use a constructible style sheet and adopted stylesheets instead of a link element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bennypowers that was a nice learning experience :-)
not using template, but separated the template and css from the main js component, WDYT ?
- use module - use web component to render the form Signed-off-by: yzamir <kobi.zamir@gmail.com>
ece9687
to
f4b422c
Compare
Signed-off-by: yzamir <kobi.zamir@gmail.com>
rose/server/web/settings/index.html
Outdated
</head> | ||
<body class="dark-theme"> | ||
<h2 class="heading">Set Game Drivers</h2> | ||
<settings-form class="form" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom-elements can't be void
<settings-form class="form" /> | |
<settings-form class="form"></settings-form> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, fixed, btw/ why did it work ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it was a hot topic 🔥
WICG/webcomponents#624
Signed-off-by: yzamir <kobi.zamir@gmail.com>
Signed-off-by: yzamir <kobi.zamir@gmail.com>
Closing in favor of specific repository per game container:
I also added a reference container for running machine learning driver: to run on all components on a cluster:
to run locally:
and for the driver, create
|
TL;DR demo
Screencast.from.2023-09-11.16-09-37.webm
Ref:
Python machine learning driver: https://github.com/yaacov/rose-ml-driver
Go land driver: https://github.com/yaacov/rose-go-driver
What this POC try to solve:
a. We can not create a k8s Pod for each driver, and let them run forever.
When a driver starts it immediately try to connect to the server and blocks other drivers from running.
b. We use python RPC protocol to comunicate between the driver and the server, this makes it hard to write
drivers in compiled languages, making us relay on .pyc file to hide implementation code.
c. We use 2.7 oriented libraries: twisted, autobahn and pytest.
Fix a and b:
Replace the RPC calls with "vanilla" client server calls, the server can now connect to selected drivers
while the other drivers still running.
Fix c:
Replace the 2.7 oriented libraries with 3.x native libraries, websockets and aiohttp.
What is changing:
The admin needs to actively select the drivers to run the match instead of waiting for two students to connect.
All students must run there drivers before the match begin.
Running locally: